<template>
  <a-modal
    :title="title"
    style="top: 5px;"
    :width="modalWidth"
    :height="modalHeight"
    :visible="visible"
    :maskClosable="false"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    :footer="null"
    :destroyOnClose=true
    cancelText="关闭">
    <a-spin :spinning="confirmLoading">
      <component :is="baseComponent" :idManage="faultReportId"></component>
    </a-spin>
  </a-modal>
</template>
<script>

  export default {
    name: 'DoTaskModal',
    components: {},
    data() {
      return {
        baseComponent:'',
        faultReportId:'',
        title:"操作",
        modalHeight: 800,
        modalWidth: 400,
        confirmLoading: false,
        visible:false,
        form: this.$form.createForm(this),
        model: {},
      }
    },
    created() {
    },
    methods: {
      showDetails(record, doTask = true) {
        this.resetScreenSize() // 调用此方法,根据屏幕宽度自适应调整抽屉的宽度
        this.faultReportId = record.busId
        let myComponent = () => import('@/views/' + record.busType + '.vue')
        this.$options.components[record.busType] = myComponent
        this.baseComponent  = record.busType
        this.visible = true

      },
      close() {
        this.$emit('close')
        this.visible = false
        this.activeKey = '1'
        this.confirmLoading = false
        // this.$refs.container.innerHTML = '';
      },
      handleOk() {
        this.$emit('ok')
      },
      handleCancel() {
        this.close()
      },

      // 根据屏幕变化,设置抽屉尺寸
      resetScreenSize() {
        let screenWidth = document.body.clientWidth
        let screenHeight = document.body.clientHeight
        this.modalHeight = screenHeight - 150
        if (screenWidth > 800) {
          this.modalWidth = screenWidth
        } else {
          this.modalWidth = 800
        }
      },
      // 获取
      getFileList() {
        let ii = 0
        let fileJson = '['
        for (let file of this.$refs.dotaskForm.fileList) {
          if (ii > 0) {
            fileJson = fileJson + `,`
          }
          fileJson = fileJson + `{
                  "id": "${file.uid}",
                  "name" :"${file.name}"
                }`
          ii = ii + 1
        }
        fileJson = fileJson + `]`
        return fileJson
      },
      getTaskDesn() {
        let taskDesn = this.$refs.dotaskForm.taskDesn
        return taskDesn
      }

    }
  }
</script>

<style lang="less" scoped>

  /** 主表单行间距 */
  .ant-form .ant-form-item {
    margin-bottom: 10px;
  }

  /** Tab页面行间距 */
  .ant-tabs-content .ant-form-item {
    margin-bottom: 0px;
  }
</style>